package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldProjectGroups;
import com.cleaningcloud.cld.service.ICldProjectGroupsService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 项目组Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/groups")
public class CldProjectGroupsController extends BaseController
{
    @Autowired
    private ICldProjectGroupsService cldProjectGroupsService;

    /**
     * 查询项目组列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CldProjectGroups cldProjectGroups)
    {
        startPage();
        List<CldProjectGroups> list = cldProjectGroupsService.selectCldProjectGroupsList(cldProjectGroups);
        return getDataTable(list);
    }

    /**
     * 导出项目组列表
     */
    @Log(title = "项目组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldProjectGroups cldProjectGroups)
    {
        List<CldProjectGroups> list = cldProjectGroupsService.selectCldProjectGroupsList(cldProjectGroups);
        ExcelUtil<CldProjectGroups> util = new ExcelUtil<CldProjectGroups>(CldProjectGroups.class);
        util.exportExcel(response, list, "项目组数据");
    }

    /**
     * 获取项目组详细信息
     */
    @GetMapping(value = "/{projectGroupsId}")
    public AjaxResult getInfo(@PathVariable("projectGroupsId") Long projectGroupsId)
    {
        return success(cldProjectGroupsService.selectCldProjectGroupsByProjectGroupsId(projectGroupsId));
    }

    /**
     * 新增项目组
     */
    @Log(title = "项目组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldProjectGroups cldProjectGroups)
    {
        return toAjax(cldProjectGroupsService.insertCldProjectGroups(cldProjectGroups));
    }

    /**
     * 修改项目组
     */
    @Log(title = "项目组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldProjectGroups cldProjectGroups)
    {
        return toAjax(cldProjectGroupsService.updateCldProjectGroups(cldProjectGroups));
    }

    /**
     * 删除项目组
     */
    @Log(title = "项目组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectGroupsIds}")
    public AjaxResult remove(@PathVariable Long[] projectGroupsIds)
    {
        return toAjax(cldProjectGroupsService.deleteCldProjectGroupsByProjectGroupsIds(projectGroupsIds));
    }
}
